﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XinjeMesProgram.Entities.RoleAndUser;

namespace XinjeMesProgram.Entities.RoleAndUser
{
    /// <summary>
    /// 权限实体类
    /// </summary>
    public class AuthPermission
    {
        /// <summary>
        /// 
        /// </summary>
        public AuthPermission()
        {
            Roles = new HashSet<RolePermissionMapping>();
        }
        /// <summary>
        /// 权限编码
        /// </summary>
        [Required]
        [Key]
        [Column(TypeName = "nvarchar(50)")]
        public string Code { get; set; }
        /// <summary>
        /// 菜单GUID
        /// </summary>
        [Column(TypeName = "nvarchar(50)")]
        public string MenuGuid { get; set; }
        /// <summary>
        /// 权限名称
        /// </summary>
        [Required]
        [Column(TypeName = "nvarchar(50)")]
        public string Name { get; set; }
        /// <summary>
        /// 权限操作码
        /// </summary>
        [Required]
        [Column(TypeName = "nvarchar(80)")]
        public string ActionCode { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public CommonEnum.Status Status { get; set; }
        /// <summary>
        /// 权限类型(0:菜单,1:按钮/操作/功能等)
        /// </summary>
        public CommonEnum.PermissionType Type { get; set; }

        /// <summary>
        /// 关联的菜单
        /// </summary>
        public AuthMenu Menu { get; set; }
        /// <summary>
        /// 权限所属的角色集合
        /// </summary>
        [NotMapped]
        public ICollection<RolePermissionMapping> Roles { get; set; }


    }
}
